package net.oschina.git.hikoyan.helloapi.processor.asyncservlet;

import net.oschina.git.hikoyan.helloapi.async.ThreadPoolManager;
import net.oschina.git.hikoyan.helloapi.common.request.BaseParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.context.request.async.DeferredResult;

/**
 * Created by yan on 17/2/8.
 */
@Service
public class AsyncTaskService {
    private final Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private ThreadPoolManager threadPoolManager;

    public void makeAsyncTask(DeferredResult<String> deferredResult, BaseParam parameter) {
        logger.info("makeAsyncTask start");
        threadPoolManager.addExecuteTask(new AsyncTask(deferredResult, parameter));
    }
}